<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/20
 * Time: 12:07
 */

namespace app\admin\controller\goods;


use app\admin\controller\BaseController;
use app\admin\model\Goods;
use think\Session;
use think\Controller;
use think\Db;
class Cycle extends BaseController
{
    public function page(){
        $goods=new Goods();
        $user=(new Session())->get("user");
        if($user["id"]){
            $items=$goods->where([
                "is_del"        =>1,
                "store_id"      =>$user["id"]
            ])->paginate(15);
        }else{
            $items=$goods->where("is_del",1)->paginate(15);
        }

        $page=$items->render();
        $this->assign("page",$page);
        $this->assign("items",$items);
        return $this->fetch("goods/cycle/index");
    }

    public function add(){
        return $this->fetch("goods/index/add");
    }

    public function create(){
        return $this->fetch("goods/index/create");
    }

    //彻底删除
    public function remove(){
        $id=$this->request->param("id");
        $goods=new Goods();
        $goods::get($id)->delete();
    }

    //恢复
    public function restore(){
        $id=$this->request->param("id");
        Goods::update([
            "id"        =>$id,
            "is_del"    =>0
        ]);
    }
}